﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MicropleSoft.WmsServiceLibrary.BusinessInterfaces;
using MicropleSoft.WmsServiceLibrary.Domain;
using MicropleSoft.WmsServiceLibrary.Models;
using MicropleSoft.WmsServiceLibrary.Unity;

namespace MicropleSoft.Web
{
    public partial class ServiceFacade
    {

        public List<PurchaseOrder> GetPurchaseOrderList(string condition)
        {
            return this.CreateAbstractServiceFactory().CreatePurchaseOrderService().Query(condition);
        }

        public void SavePurchaseOrders(List<PurchaseOrder> purchaseOrders)
        {
            this.CreateAbstractServiceFactory().CreatePurchaseOrderService().Save(purchaseOrders.ToList<IPurchaseOrder>());
        }

        public void SavePurchaseOrders(List<PurchaseOrder> purchaseOrders, List<String> notUpdateProperties)
        {
            this.CreateAbstractServiceFactory().CreatePurchaseOrderService().Save(purchaseOrders.ToList<IPurchaseOrder>(), notUpdateProperties);
        }

        public List<PurchaseOrderDetail> GetPurchaseOrderDetailList(string condition)
        {
            return this.CreateAbstractServiceFactory().CreatePurchaseOrderDetailService().Query(condition);
        }

        public void SavePurchaseOrderDetails(List<PurchaseOrderDetail> purchaseOrderDetails)
        {
            this.CreateAbstractServiceFactory().CreatePurchaseOrderDetailService().Save(purchaseOrderDetails.ToList<IPurchaseOrderDetail>());
        }

        public void SavePurchaseOrderDetails(List<PurchaseOrderDetail> purchaseOrderDetails, List<String> notUpdateProperties)
        {
            this.CreateAbstractServiceFactory().CreatePurchaseOrderDetailService().Save(purchaseOrderDetails.ToList<IPurchaseOrderDetail>(), notUpdateProperties);
        }
       
        public void SavePurchaseOrderWrap(PurchaseOrderWrap purchaseOrderWrap)
        {
            var purchaseOrderLogic = ContainerFactory.GetObjectFromUnityContainer<IPurchaseOrderLogic>();
            purchaseOrderLogic.Save(purchaseOrderWrap);
        }

       public  PurchaseOrderWrap GetPurchaseOrderWrapByPo(string poId, string whId)
       {
           var purchaseOrderLogic = ContainerFactory.GetObjectFromUnityContainer<IPurchaseOrderLogic>();
           return purchaseOrderLogic.GetPurchaseOrderWrapByPo(poId, whId);
       }
    }
}